<?php
namespace Home\Model;
use Home\Common\BaseModel;
use \Think\Db;
use Think\Model;

class AddressModel extends BaseModel{

    // 默认 会员ID
    //public $member_id = 714;

    /**
     * @return array
     * 选择收货地址
     */
    public function changeAddress(){

        $result = M('b2c_member_addrs')->where(array('member_id'=>session('userInfo')['member_id']))->save(array('def_addr'=>0));
        $dt = M('b2c_member_addrs')->where(array('addr_id'=>I('post.id')))->save(array('def_addr'=>1));
        if($dt){
            return array('msg'=>'更新默认地址成功','status'=>1,'url'=>url('home/carts/cart'));
        }else{
            return array('msg'=>'更新默认地址失败','status'=>0);
        }

    }

}